/**
 * Copyright 2009 cestum.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cestum.cave.presenter.wave.utils {

import flash.utils.ByteArray;

import org.cestum.cave.presenter.wave.HashedVersion;


/**
 * Utility class for creating Hashed Versions with Crypto dependencies, this is intented
 * for "full" i.e. not lightweight implementations.
 *
 *
 *
 */
public class HashedVersionFactoryImpl extends HashedVersionZeroFactoryImpl {

  /** The first N bits of a SHA-256 hash are stored in the hash must be <= 256 */
  private static var HASH_SIZE_BITS:int= 160;
  
  static var hashSizeBits:int = HASH_SIZE_BITS;
  
  
  override public function createUsingDelta(appliedDeltaBytes:ByteArray,
						 hashedVersionAppliedAt:HashedVersion, 
						 operationsApplied:int):HashedVersion {
		  
		  return new HashedVersion(hashedVersionAppliedAt.getVersion() + operationsApplied,
			  calculateHash(hashedVersionAppliedAt.getHistoryHash(), appliedDeltaBytes));
	  }
  private function calculateHash(hash:ByteArray, appliedBytes:ByteArray):ByteArray {
	  //FIXME
	  return hash;
  }
}
}